package com.example.chess.base;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.chess.utils.Utils;

public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStatusBarStyle();
        setContentView(setLayoutResource());
        initView();
    }

    private void setStatusBarStyle() {
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    @LayoutRes
    protected abstract int setLayoutResource();

    protected abstract void initView();

    protected void fitWithStatusBar(@IdRes int id) {
        Utils.fitWithStatusBar(findViewById(id));
    }

    public void finish(View view) {
        onBackPressed();
    }

}
